public class VarParam{
	//这是测试变参
	public static void main(String[] args){
		int[] array = getArray(10,2,20);
		printArray(array);
		System.out.println(max(array));
	}
	static int max(int ... values){
		int len = values.length;
		if(len>0){
			int max = values[0];
			for(int i =0;i<len;i++){
				if(max<values[i]){
					max = values[i];
				}
			}
			return max;
		}else{
			return -1;
		}
	}
	static int[] getArray(int length,int min,int max){
		int[] temp =new int[length];
		
		for(int i =0;i<length;i++){
			temp[i] = getRanNum(min,max);
		}
		return temp;
	}
	static int getRanNum(int min,int max){
		int num = (int)(Math.random()*(max-min+1)+min);
		return num;
	}
	static void printArray(int[] array){
		System.out.print("[");
		for(int i= 0;i<array.length;i++){
			if(i==array.length-1){
				System.out.print(array[i]);
			}
			else{
			System.out.print(array[i]+",");
			}
			
		}
		System.out.println("]");
	}
}